// import request from '@/utils/request'
import request from '@/views/kzzx/utils/request'

const unitId = "ZJ3950"
const tenant="91230100127049733H"
const targetId ="ZJ3950"
const imagePath = "CameraImages"

/**
 * 图片通用链接
 */
export function image_original(filename){
  return request.get('/api/image/original',{params:{path:imagePath,filename:filename}})
}

/**
 * 3能耗管理 EMS 接口
 */

/**
 * 3.1电能累计
 */
export function ems_electric_summary(){
  return request.get('/api/ems/electric/summary',{params:{unitId:unitId}})
}

/**
 * 3.2用电历史
 * @param startTime
 * @param endTime
 * @param win
 * @param winUnit
 */
export function ems_electric_history(startTime, endTime,win,winUnit){
  return request.get('/api/ems/electric/history',{params:{unitId:unitId,startTime:startTime,endTime:endTime,win:win,winUnit:winUnit}})
}

/**
 * 3.3单位产出用电趋势
 */
export function ems_dongqing_electric_perProduct(startTime, endTime,win,winUnit){
  return request.get('/api/mes/dongqing/electricPerProduct',{params:{unitId:unitId,startTime:startTime,endTime:endTime,win:win,winUnit:winUnit}})
}



/**
 * 4.智能安防接口
 */

/**
 * 事件累计
 * @param startTime
 * @param endTime
 * @param win
 * @param winUnit
 */
export function iss_event_summary(){
  return request.get('/api/iss/event/summary',{params:{tenant:tenant}})
}

/**
 * 4.3事件类型分段聚合统计
 * @param startTime
 * @param endTime
 * @param win
 * @param winUnit
 */
export function iss_event_stat_window(startTime, endTime,win,winUnit){
  return request.get('/api/iss/event/stat/window',{params:{tenant:tenant,startTime:startTime,endTime:endTime,win:win,winUnit:winUnit}})
}

/**
 * 4.2事件类型统计
 */
export function iss_event_stat_type(startTime, endTime){
  return request.get('/api/iss/event/stat/type',{params:{tenant:tenant,startTime:startTime,endTime:endTime}})
}

/**
 * 告警事件

 */
export function iss_event_type_unconfirmed(){
  return request.get('/api/iss/event/unconfirmed',{params:{tenant:tenant}})
}

/**
 * 事件确认
 * @param eventId
 * @param action
 */
export function iss_event_confirm(eventId,action){
  return request({
    url: '/api/iss/event/confirm?action=已知&eventId=5edum1awz2m8',
    method: 'post',
    data: {}
  })
}

/**
 * 5.MES生产数据接口
 */
/**
 * 5.1投料及产出量累计
 */
export function mes_dongqing_summary (startTime, endTime) {
  return request.get('/api/mes/dongqing/summary',{params:{unitId:unitId,startTime:startTime,endTime:endTime}})
}

/**
 * 5.2历史生产数据
 */
export function mes_dongqing_history (startTime, endTime,win,winUnit) {
  return request.get('/api/mes/dongqing/history',{params:{unitId:unitId,startTime:startTime,endTime:endTime,win:win,winUnit:winUnit}})
}

/**
 * 6.数字绩效管理 DPM 接口
 */
export function dpm_oee (startTime, endTime) {
  return request.get('/api/dpm/plant/kpi/oee',{params:{targetId:targetId,startTime:startTime,endTime:endTime}})
}

/**
 * OEE 趋势
 * @param startTime
 * @param endTime
 * 日历,时间利用率，计划时间利用率，性能利用率，合格率、OEE、TEEP
 */
export function dpm_oee_trend (startTime, endTime) {
  return request.get('/api/dpm/plant/kpi/oee/trend',{params:{targetId:targetId,startTime:startTime,endTime:endTime}})
}

/**
 * MTBF、MTTR
 */
export function dpm_mtbf (startTime, endTime) {
  return request.get('/api/dpm/plant/kpi/mtbf',{params:{targetId:targetId,startTime:startTime,endTime:endTime}})
}

/**
 * 启停时间统计
 */
export function dpm_runStopDuration(startTime, endTime) {
  return request.get('/api/dpm/runStopDuration',{params:{targetId:targetId,startTime:startTime,endTime:endTime}})
}


/**
 * 停机时长趋势接口
 */
export function duration_groupByMonth(startTime, endTime) {
  return request.get('/api/MachineShutdownEvent/duration/groupByMonth',{params:{targetId:targetId,startTime:startTime,endTime:endTime}})
}

/**
 * 8.设备运行状态统
 */

/**
 * 设备运行状态统计
 */
export function plant_state_stat (groupByRegion) {
  return request.get('/api/plant/state/stat',{params:{tenant:tenant,groupByRegion:groupByRegion}})
}


/**
 * 告警趋势
 */
export function data_alarm_trend (startTime,endTime,win,winUnit) {
  return request.get('/api/data/alarm/trend',{params:{tenant:tenant,startTime:startTime,endTime:endTime,win:win,winUnit:winUnit}})
}

/**
 * 实时数据接
 */
export function device_data (deviceId){
  return request.get('/api/device/data/latest',{params:{deviceId:deviceId}})
}

/**
 * 查询报警标准
 * @param deviceId
 */
export function alarm_rule (deviceId){
  return request.get('/api/data/alarm/ruleOfDevice',{params:{deviceId:deviceId}})
}